<extend name="Common/back" />

<block name="content">
    <div id="content">
        <div class="page-header">
            <div class="container-fluid">
                <div class="pull-right">
                    <button type="submit" form="form-set" data-toggle="tooltip" title="保存" class="btn btn-primary">
                        <i class="fa fa-save"></i>
                    </button>
                    <a href="{:U('list')}" data-toggle="tooltip" title="取消" class="btn btn-default">
                        <i class="fa fa-reply"></i>
                    </a>
                </div>
                <h1>配置</h1>
                <ul class="breadcrumb">
                    <li>
                        <a href="{:U('Manage/index')}">首页</a>
                    </li>
                    <li>
                        <a href="javascript:;">配置</a>
                    </li>
                </ul>
            </div>
        </div>
        <div class="container-fluid">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">
                        <i class="fa fa-pencil"></i>
                        设置配置
                    </h3>
                </div>
                <div class="panel-body">
                    <form action="{:U('set')}" method="post" enctype="multipart/form-data" id="form-set" class="form-horizontal">
                        <if condition="isset($data['setting_id'])">
                            <input type="hidden" name="setting_id" value="{$data['setting_id']}" id="input-setting_id">
                        </if>
                        <ul class="nav nav-tabs">
                            <volist name="group_setting_list" id="group">
                                <li class="<if condition="$i eq 1">active</if>">
                                    <a href="#tab-{$group['setting_group_id']}" data-toggle="tab">{$group['group_title']}</a>
                                </li>
                            </volist>
                        </ul>
                        <div class="tab-content">
                            <volist name="group_setting_list" id="group">
                                <div class="tab-pane <if condition="$i eq 1">active</if>" id="tab-{$group['setting_group_id']}">
                                    <volist name="group['setting_list']" id="setting">
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label" for="input-{$setting['key']}">{$setting['title']}</label>
                                        <div class="col-sm-10">
                                            <switch name="setting.type_title">
                                                <case value="text">
                                            <input type="text" class="form-control" placeholder="" name="setting[{$setting['setting_id']}]"
                                                   id="input-{$setting['key']}" value="{$setting['value']}"/>
                                                </case>
                                                <case value="textarea">
                                                    <textarea   class="form-control" placeholder="" name="setting[{$setting['setting_id']}]"
                                                                id="input-{$setting['key']}" >
                                                        {$setting['value']}
                                                    </textarea>
                                                </case>
                                                <case value="select-multi">
                                                    <select class="form-control"  name="setting[{$setting['setting_id']}]"
                                                           id="input-{$setting['key']}" multiple>
                                                        <volist name="setting.options" id="option">
                                                            <option value="{$option['setting_option_id']}" <if condition="in_array(
                                                            $option['setting_option_id'],$setting['value_list'])">selected</if>
                                                            >{$option['option_title']}</option>
                                                        </volist>
                                                    </select>
                                                </case>
                                            </switch>
                                        </div>
                                    </div>
                                    </volist>
                                </div>
                           </volist>

                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</block>

<block name="appendJs">
    <script src="__PUBLIC__/Back/validate/jquery.validate.min.js"></script>
    <script src="__PUBLIC__/Back/validate/additional-methods.min.js"></script>
    <script src="__PUBLIC__/Back/validate/localization/messages_zh.min.js"></script>

    <script>
    // 表单的JS验证
        $(function(){
            $('#form-set').validate({});
        });
    </script>

</block>